$(function(){
    tmplInit();
    openDivInit();

    Egame.common.tabs.init("#tabChange", {ev:"mouseover", tabOnClass:"tab_on"});
    //复写全局默认参数
    //pCommon.slider.opts.time = 3000;
    pCommon.slider.init("#slidBanner1", {type: "v"});
    pCommon.slider.init("#slidBanner2", {type: "h"});
    pCommon.slider.init("#slidBanner3", {type: "a"});
    pCommon.slider.init("#slidBanner4", {type: "n"});

    pCommon.back2top.init("#back2top");

});

function tmplInit() {
    var dataObject = {
        id: 101,
        profile_image_url: 'http://www.baidu.com/img/bdlogo.gif',
        from_user: "zc",
        text: "hahahahaah"
    }
    var results = document.getElementById("results");
    var html = "";
    html  = Egame.tmpl("item_tmpl", dataObject);
    results.innerHTML = html;


    var userObj =
    {
        users:[
                {
                    url: "www.user.com",
                    name: "zc"
                },
                {
                    url: "www.user2.com",
                    name: "zc2"
                },
                {
                    url: "www.user2.com",
                    name: "zc3"
                }
            ]
    };
    var results2 = document.getElementById("results2");
    var html2 = "";
    html2  = Egame.tmpl("user_tmpl", userObj);
    results2.innerHTML = html2;
}

//弹出层
function openDivInit() {
    var iframeDiv, pageDiv, alertDiv, confirmDiv, tipsDiv, msgDiv;

    //loading
    //$.layer({
        //type : 3,
        //time: 2,
        //shade: false,
        //border: false,
        //loading: {type: 2}
    //});


    $("#iframeDiv").click(function(){
        pageDiv = $.layer({
            title: "iframeDiv",
            type : 2,
            area : ['500px', '500px'],
            closeBtn : [0, true],
            iframe: {
                src: 'http://sentsin.com'
            }
        });

    });

    $("#pageDiv").click(function(){
        pageDiv = $.layer({
            title: "登录",
            type : 1,
            area : ['500px', 'auto'],
            move : false,
            closeBtn : [1, true],
            page : {dom : '#results'}
        });

    });

    $("#alertDiv").click(function(){
        alertDiv = layer.alert("内容", 0, "标题", function(){
            alert("回调");
        });
    });

    $("#confirmDiv").click(function(){
        confirmDiv = layer.confirm("内容", function(){
            alert("回调1,关闭tipsDiv");
            //关闭tipsDiv
            layer.close(tipsDiv);
        }, "标题", function(){
            alert("回调2");
        });
    });

    $("#msgDiv").click(function(){
        msgDiv = layer.msg("内容",2, 1, function(){
            alert("msgDiv索引值：" + msgDiv);
        });
    });

    $("#tipsDiv").click(function(){
        tipsDiv = layer.tips("这是小提示", this);
    });
}
